var idNum, depth;

jQuery.fn.extend({
    floatPanelClose: function() {
        var a = $(this).attr("kdirection"), b = $(this).floatPanelGetState();
        b && ("top" == a || "left" == a ? $(this).find("#searchBtn").click() : ("bottom" == a || "right" == a) && $(this).find("#searchBtn2").click());
    },
    floatPanelOpen: function() {
        var a = $(this).attr("kdirection"), b = $(this).floatPanelGetState();
        b || ("top" == a || "left" == a ? $(this).find("#searchBtn").click() : ("bottom" == a || "right" == a) && $(this).find("#searchBtn2").click());
    },
    floatPanelChangeState: function() {
        var a = $(this).attr("kdirection");
        "top" == a || "left" == a ? $(this).find("#searchBtn").click() : ("bottom" == a || "right" == a) && $(this).find("#searchBtn2").click();
    },
    floatPanelGetState: function() {
        var a, b = $(this).attr("kdirection");
        return "top" == b ? a = parseInt($(this)[0].style.top) < 0 ? !1 : !0 : "left" == b ? a = parseInt($(this)[0].style.left) < 0 ? !1 : !0 : "right" == b ? a = parseInt($(this)[0].style.right) < 0 ? !1 : !0 : "bottom" == b && (a = parseInt($(this)[0].style.bottom) < -2 ? !1 : !0), 
        a;
    },
    floatPanelRender: function() {
        var a;
        $(this).find(".searchPan_con").length > 0 ? $(this).buildBox() : (a = $(this).html(), 
        $(this).empty(), new jQuery.FloatPanel(this, a));
    },
    buildBox: function() {
        var b, a = $(this);
        a.find("#searchBtn").unbind("click"), a.find("#searchBtn2").unbind("click"), a.find("#searchBtn").attr("title", a.attr("beforeClickText")), 
        a.find("#searchBtn").text(a.attr("beforeClickText")), a.find("#searchBtn2").attr("title", a.attr("beforeClickText")), 
        a.find("#searchBtn2").text(a.attr("beforeClickText")), a.find("#searchPan").width(Number(a.attr("panelWidth"))), 
        0 == a.attr("iframe") || "false" == a.attr("iframe") ? "0" == a.attr("panelHeight") ? b = a.find(".searchPan_con").height() : (b = Number(a.attr("panelHeight")), 
        a.find(".searchPan_con").height(b)) : "0" == a.attr("panelHeight") ? b = a.find(".searchPan_con").height() : (b = Number(a.attr("panelHeight")), 
        a.find("iframe").height(b)), "top" == a.attr("kdirection") ? "hide" == a.attr("init") ? (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? a.animate({
            top: -b - 12
        }, {
            duration: 1e3
        }) : a.css({
            top: -b - 12
        }), a.find("#searchBtn").toggle(function() {
            a.animate({
                top: "0"
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                top: -b - 12
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        })) : (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? (a.css({
            top: -b - 12
        }), a.animate({
            top: 0
        }, {
            duration: 1e3
        })) : a.css({
            top: 0
        }), a.find("#searchBtn").toggle(function() {
            a.animate({
                top: -b - 12
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                top: "0"
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        })) : "left" == a.attr("kdirection") ? (a.width(Number(a.attr("panelWidth")) + 30), 
        "hide" == a.attr("init") ? (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? (a.css({
            top: Number(a.attr("topDistance"))
        }), a.animate({
            top: Number(a.attr("topDistance")),
            left: -Number(a.attr("panelWidth")) - 1
        }, {
            duration: 1e3
        })) : a.css({
            top: Number(a.attr("topDistance")),
            left: -Number(a.attr("panelWidth")) - 1
        }), a.find("#searchBtn").toggle(function() {
            a.animate({
                top: a.attr("topDistance"),
                left: 0
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                top: a.attr("topDistance"),
                left: -Number(a.attr("panelWidth")) - 1
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        })) : (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? (a.css({
            top: Number(a.attr("topDistance")),
            left: -Number(a.attr("panelWidth")) - 1
        }), a.animate({
            top: Number(a.attr("topDistance")),
            left: 0
        }, {
            duration: 1e3
        })) : a.css({
            top: Number(a.attr("topDistance")),
            left: 0
        }), a.find("#searchBtn").toggle(function() {
            a.animate({
                top: Number(a.attr("topDistance")),
                left: -Number(a.attr("panelWidth")) - 1
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                top: Number(a.attr("topDistance")),
                left: 0
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        }))) : "right" == a.attr("kdirection") ? (a.width(Number(a.attr("panelWidth")) + 30), 
        "hide" == a.attr("init") ? (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? (a.css({
            top: Number(a.attr("topDistance"))
        }), $(".searchMain").filter("[id=" + parentId + "]").animate({
            top: Number(a.attr("topDistance")),
            right: -Number(a.attr("panelWidth")) - 1
        }, {
            duration: 1e3
        })) : a.css({
            top: Number(a.attr("topDistance")),
            right: -Number(a.attr("panelWidth")) - 1
        }), a.find("#searchBtn2").toggle(function() {
            a.animate({
                top: Number(a.attr("topDistance")),
                right: 0
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                top: Number(a.attr("topDistance")),
                right: -Number(a.attr("panelWidth")) - 1
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        })) : (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? (a.css({
            top: Number(a.attr("topDistance")),
            right: -Number(a.attr("panelWidth")) - 1
        }), a.animate({
            top: Number(a.attr("topDistance")),
            right: 0
        }, {
            duration: 1e3
        })) : a.css({
            top: Number(a.attr("topDistance")),
            right: 0
        }), a.find("#searchBtn2").toggle(function() {
            a.animate({
                top: Number(a.attr("topDistance")),
                right: -Number(a.attr("panelWidth")) - 1
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                top: Number(a.attr("topDistance")),
                right: 0
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        }))) : "bottom" == a.attr("kdirection") && ("hide" == a.attr("init") ? (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? a.animate({
            bottom: -b - 12
        }, {
            duration: 1e3
        }) : a.css({
            bottom: -b - 12
        }), a.find("#searchBtn2").toggle(function() {
            a.animate({
                bottom: -2
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                bottom: -b - 12
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        })) : (1 == a.attr("animatefirst") || "true" == a.attr("animatefirst") ? (a.css({
            bottom: -b - 12
        }), a.animate({
            bottom: -2
        }, {
            duration: 1e3
        })) : a.css({
            bottom: -2
        }), a.find("#searchBtn2").toggle(function() {
            a.animate({
                bottom: -b - 12
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "hide");
            }), $(this).attr("title", a.attr("afterClickText")), $(this).text(a.attr("afterClickText"));
        }, function() {
            a.animate({
                bottom: -2
            }, parseInt(a.attr("duration")), function() {
                a.trigger("stateChange", "show");
            }), $(this).attr("title", a.attr("beforeClickText")), $(this).text(a.attr("beforeClickText"));
        }))), a[0].style.visibility = "visible";
    }
}), idNum = 0, depth = 700, jQuery.FloatPanel = function(a, b) {
    var c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, s;
    if (a.attr("id") || a.attr("id", "floatPanel_auto_" + idNum), idNum++, a.attr("depth") ? a.css({
        zIndex: Number(a.attr("depth"))
    }) : a.css({
        zIndex: Number(depth)
    }), depth++, c = uncompile(quiLanguage.floatPanel.beforeClickText), d = uncompile(quiLanguage.floatPanel.afterClickText), 
    e = 500, f = !0, g = 400, h = "tc", i = "top", j = !1, k = "hide", l = 30, m = 0, 
    n = "top", a.attr("beforeClickText") ? c = a.attr("beforeClickText") : a.attr("beforeClickText", c), 
    a.attr("afterClickText") ? d = a.attr("afterClickText") : a.attr("afterClickText", d), 
    a.attr("duration") ? e = Number(a.attr("duration")) : a.attr("duration", e), "false" == a.attr("animatefirst") || 0 == a.attr("animatefirst") ? f = !1 : a.attr("animatefirst", f), 
    a.attr("panelWidth") ? g = Number(a.attr("panelWidth")) : a.attr("panelWidth", g), 
    a.attr("direction") && (h = a.attr("direction")), a.attr("kDirection") && (i = a.attr("kDirection")), 
    a.attr("iframe") ? j = "false" == a.attr("iframe") || 0 == a.attr("iframe") ? !1 : a.attr("iframe") : a.attr("iframe", "false"), 
    a.attr("init") ? k = a.attr("init") : a.attr("init", k), a.attr("topDistance") ? l = Number(a.attr("topDistance")) : a.attr("topDistance", l), 
    a.attr("panelHeight") ? m = Number(a.attr("panelHeight")) : a.attr("panelHeight", m), 
    o = $("<div id='searchBtnCon2'><button id='searchBtn2' type='button'></button></div><div id='clear2'></div><div id='searchPan'><div class='searchPan_con'></div></div><div id='clear'></div><div id='searchBtnCon'><button id='searchBtn' type='button'></button></div>"), 
    a.append(o), a[0].style.visibility = "hidden", "tl" == h) a.find("#searchBtnCon2").css({
        display: "none"
    }), a.css({
        paddingLeft: "10px"
    }); else if ("tc" == h) a.css({
        textAlign: "center",
        width: "100%"
    }), a.find("#searchPan").css({
        marginLeft: "auto",
        marginRight: "auto"
    }), a.find("#searchBtnCon").css({
        textAlign: "center"
    }), a.find("#searchBtnCon2").css({
        display: "none"
    }); else if ("tr" == h) a.css({
        textAlign: "right",
        right: 0,
        paddingRight: "10px"
    }), document.all || a.find("#searchPan").css({
        "float": "right"
    }), a.find("#searchBtnCon").css({
        textAlign: "right"
    }), a.find("#searchBtnCon2").css({
        display: "none"
    }); else if ("ml" == h) a.find("#searchPan").css({
        "float": "left"
    }), a.find("#searchBtnCon").css({
        "float": "left"
    }), a.find("#searchBtnCon2").css({
        display: "none"
    }), n = "left"; else if ("mr" == h) a.find("#searchPan").css({
        "float": "left"
    }), a.find("#searchBtnCon2").css({
        "float": "left"
    }), a.find("#searchBtnCon").css({
        display: "none"
    }), n = "right"; else if ("bl" == h) a.find("#searchBtnCon").css({
        display: "none"
    }), a.css({
        left: "5"
    }), n = "bottom"; else if ("bc" == h) a.css({
        textAlign: "center",
        width: "100%"
    }), a.find("#searchPan").css({
        marginLeft: "auto",
        marginRight: "auto"
    }), a.find("#searchBtnCon2").css({
        textAlign: "center"
    }), a.find("#searchBtnCon").css({
        display: "none"
    }), n = "bottom"; else {
        if ("br" != h) return alert(uncompile(quiLanguage.floatPanel.errorMessage1)), void 0;
        a.css({
            textAlign: "right",
            right: 0,
            paddingRight: "10px"
        }), document.all || a.find("#searchPan").css({
            "float": "right"
        }), a.find("#searchBtnCon2").css({
            textAlign: "right"
        }), a.find("#searchBtnCon").css({
            display: "none"
        }), n = "bottom";
    }
    a.attr("kDirection", n), "top" == n ? (a.find("#searchPan")[0].className = "searchPanTop", 
    a.find("#searchBtn")[0].className = "searchBtnTop", a.find("#searchBtnCon")[0].className = "searchBtnConTop", 
    a.find("#searchBtnCon2")[0].className = "searchBtnConTop", a.find("#clear")[0].className = "clearTop") : "left" == n ? (a.find("#searchPan")[0].className = "searchPanLeft", 
    a.find("#searchBtn")[0].className = "searchBtnLeft", a.find("#searchBtnCon")[0].className = "searchBtnConLeft", 
    a.find("#searchBtnCon2")[0].className = "searchBtnConLeft", ("true" == a.attr("showCloseBtn") || 1 == a.attr("showCloseBtn")) && (p = $('<a class="floatPanelClose"></a>'), 
    a.find("#searchBtnCon").append(p), p.click(function() {
        a.trigger("close", a);
    }))) : "right" == n ? (a.find("#searchPan")[0].className = "searchPanRight", a.find("#searchBtn2")[0].className = "searchBtnRight", 
    a.find("#searchBtnCon")[0].className = "searchBtnConRight", a.find("#searchBtnCon2")[0].className = "searchBtnConRight", 
    ("true" == a.attr("showCloseBtn") || 1 == a.attr("showCloseBtn")) && (q = $('<a class="floatPanelClose"></a>'), 
    a.find("#searchBtnCon2").append(q), q.click(function() {
        a.trigger("close", a);
    }))) : "bottom" == n && (a.find("#searchPan")[0].className = "searchPanBottom", 
    a.find("#searchBtn2")[0].className = "searchBtnBottom", a.find("#searchBtnCon")[0].className = "searchBtnConBottom", 
    a.find("#searchBtnCon2")[0].className = "searchBtnConBottom", a.find("#clear2")[0].className = "clearTop"), 
    j ? m > 0 ? (s = $("<IFRAME scrolling=auto width=100%  frameBorder=0 id=frmcontent name=frmcontent allowTransparency=true></IFRAME>"), 
    a.find("div[class='searchPan_con']").append(s), s.attr("src", j), s.bind("load", function() {
        var b = s[0];
        try {
            b.contentWindow.document.body.style.backgroundColor = "transparent", b.contentWindow.document.body.style.backgroundImage = "none";
        } catch (c) {}
        a.buildBox();
    })) : alert(uncompile(quiLanguage.floatPanel.errorMessage2)) : (a.find("div[class='searchPan_con']").append(b), 
    a.buildBox());
};